package com.yj.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yj.po.User;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


public interface UserMapper extends BaseMapper<User> {

    @Select("select * from my_user where username =#{userName}")
    User findUserByUserName(String userName);


    @Select("select my_menu.href,my_menu.permission from my_user " +
            "left join my_user_role on my_user.id = my_user_role.user_id " +
            "left join my_role_menu on my_user_role.id = my_role_menu.role_id " +
            "left join my_menu on my_role_menu.menu_id = my_menu.id " +
            "where my_user.username = #{userName}")
    @Results(
            value = {
                    @Result(column = "href", property = "href"),
                    @Result(column = "permission", property = "permission")
            }
    )
    List<Map<String,String>> findUserRoleMenuByUserName(String userName);
}
